package com.scsj.supermarket.view.activity.shopermodel;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;

import com.scsj.supermarket.R;
import com.scsj.supermarket.bean.ShoperCommitInfoBean;
import com.scsj.supermarket.utils.SkipUtils;
import com.scsj.supermarket.view.activity.baseactivitymodel.BaseActivity;

import es.dmoral.toasty.Toasty;

/**
 * 商家申请入驻第二步
 */
public class RegisterSecondStepActivity extends BaseActivity implements View.OnClickListener{
    private RelativeLayout nextBtnRl;
    private ShoperCommitInfoBean shoperCommitInfoBean;
    private RadioGroup delivieryType;
    private RadioButton radioButton;

    //标准配置
    private EditText standardDistanceEt,standardWeightEt,standardPriceEt;
    //增额配置
    private EditText incrementWeightEt,incrementWeightPriceEt;
    private EditText diatanceWeightEt,diatanceWeightPriceEt;
    //最高限制
    private EditText farthestDiatanceEt;
    private EditText mostWeightEt;


    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_register_second_step);
    }

    @Override
    protected void initView() {

        nextBtnRl= findViewById(R.id.registersecond_next_rl);
        delivieryType= findViewById(R.id.deliviery_type);
        //标准距离
        standardDistanceEt= findViewById(R.id.secondregister_distance_et);
        //标准重量
        standardWeightEt= findViewById(R.id.secondregister_weight_et);
        //标准配送费
        standardPriceEt= findViewById(R.id.secondregister_price_et);

        //增距
        incrementWeightEt= findViewById(R.id.secondregister_kg_et);
        //增距价格
        incrementWeightPriceEt= findViewById(R.id.secondregister_sallary_et);
        //增重
        diatanceWeightEt= findViewById(R.id.secondregister_mitter_et);
        //增重价格
        diatanceWeightPriceEt= findViewById(R.id.secondregister_money_et);

        //最远距离
        farthestDiatanceEt= findViewById(R.id.secondregister_highmitter_et);
        //重量最多
        mostWeightEt= findViewById(R.id.secondregister_highkg_et);

    }

    @Override
    protected void initListener() {
        nextBtnRl.setOnClickListener(this);

    }

    @Override
    protected void initData() {
        shoperCommitInfoBean= (ShoperCommitInfoBean) getIntent().getSerializableExtra("delivery_shopdata");
        //获取第一个页面传递过来的数据
        //店铺名字
        String shopName = shoperCommitInfoBean.getShopName();
        //先打印一下看看
        Log.e("传过来的店铺名字：",shopName+"店");
        Log.e("传过来的店铺类型：",shoperCommitInfoBean.getShopType()+"类型");

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){

            case R.id.registersecond_next_rl:
                //配送方式
                radioButton = findViewById(delivieryType.getCheckedRadioButtonId());

                String standardDistance= standardDistanceEt.getText().toString();
                String standardWeight= standardWeightEt.getText().toString();
                String standardPrice= standardPriceEt.getText().toString();

                String incrementWeight= incrementWeightEt.getText().toString();
                String incrementWeightPrice= incrementWeightPriceEt.getText().toString();
                String diatanceWeight= diatanceWeightEt.getText().toString();
                String diatanceWeightPrice= diatanceWeightPriceEt.getText().toString();

                String farthestDiatance= farthestDiatanceEt.getText().toString();
                String mostWeight= mostWeightEt.getText().toString();

                if (TextUtils.isEmpty(standardDistance)){
                    Toasty.info(RegisterSecondStepActivity.this, "标准距离不能为空").show();
                    return;
                }else if (TextUtils.isEmpty(standardWeight)){
                    Toasty.info(RegisterSecondStepActivity.this, "标准重量不能为空").show();
                    return;
                }else if (TextUtils.isEmpty(standardPrice)){
                    Toasty.info(RegisterSecondStepActivity.this, "标准配送费不能为空").show();
                    return;
                }else if (TextUtils.isEmpty(incrementWeight)) {
                    Toasty.info(RegisterSecondStepActivity.this, "请完善增额配置").show();
                    return;
                }else if (TextUtils.isEmpty(incrementWeightPrice)) {
                    Toasty.info(RegisterSecondStepActivity.this, "请完善增额配置").show();
                    return;
                }else if (TextUtils.isEmpty(diatanceWeight)) {
                    Toasty.info(RegisterSecondStepActivity.this, "请完善增额配置").show();
                    return;
                }else if (TextUtils.isEmpty(diatanceWeightPrice)) {
                    Toasty.info(RegisterSecondStepActivity.this, "请完善增额配置").show();
                    return;
                }else if (TextUtils.isEmpty(farthestDiatance)) {
                    Toasty.info(RegisterSecondStepActivity.this, "请完善最高限制").show();
                    return;
                }else if (TextUtils.isEmpty(mostWeight)) {
                    Toasty.info(RegisterSecondStepActivity.this, "请完善最高限制").show();
                    return;
                }else {
                    shoperCommitInfoBean.setStandardDistance(standardDistance);
                    shoperCommitInfoBean.setStandardWeight(standardWeight);
                    shoperCommitInfoBean.setStandardPrice(standardPrice);

                    shoperCommitInfoBean.setIncrementWeight(incrementWeight);
                    shoperCommitInfoBean.setIncrementWeightPrice(incrementWeightPrice);
                    shoperCommitInfoBean.setIncrementDistance(diatanceWeight);
                    shoperCommitInfoBean.setIncrementDistancePrice(diatanceWeightPrice);

                    shoperCommitInfoBean.setFarthestDistance(farthestDiatance);
                    shoperCommitInfoBean.setMostWeight(mostWeight);

                    SkipUtils.toRegisterThirdStep(this,shoperCommitInfoBean);
                }
                break;
        }
    }
}
